﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CardGamesLibrary;
using CardGamesLibrary.Cards.Decks;
using CardGamesLibrary.Games;
using CardGamesLibrary.Poker;
using CardGamesLibrary.Solitaire;

namespace CardGames.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var fd = new FrenchDeck();
            fd.Reset();

            List<SolitairePile> piles = new List<SolitairePile>();
            for (int i = 0; i < 4; i++)
            {
                piles.Add(new SolitaireTopPile());
            }
            
            var SingleGame = new SolitaireGameTable();
            
            // loop until we have 4 piles of 13 cards each
            while(piles.Count(a=>a.Count == 13) < 4)
            {
                if (fd.Count == 0)
                    fd.Reset();

                
                var card = fd.GrabRandomCard();

                foreach (var item in piles)
                {
                    if (item.CanAdd(card))
                    { 
                        item.Add(card);
                        break; //get next card
                    }
                }
                
            }

            // use the debugger and watch the piles. they should be well structured and each of a different suite.


            var pokerTable = new PokerTable(8);
            
            var game = new TexasHoldemPokerGame(pokerTable);

            pokerTable.AddPlayer(new PokerPlayer("seb", 500, false), 200);
            pokerTable.AddPlayer(new PokerPlayer("piotr", 500, false), 200);

            pokerTable.AddPlayer(new PokerPlayer("computer1", 500, true), 200);
            pokerTable.AddPlayer(new PokerPlayer("computer2", 500, true), 200);


            game.StartGame();

            while (!game.Finished)
            {
                game.NextTurn();
            }

            System.Console.ReadLine();
        }
    }
}
